home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
shareware
/
intuition
/
reqtools_2.1e
/
glue
/
gcc
/
gcc_glue.lha
/
demo.c
next >
Wrap
C/C++ Source or Header
|
1993-02-27
|
16KB
|
521 lines
/*********************************
* *
* reqtools.library (V38) *
* *
* Release 2.0 *
* *
* (c) 1991-1993 Nico François *
* *
* demo.c *
* *
* This source is public domain *
* in all respects. *
* *
*********************************/
/*********************************
* *
* GCC demo *
* *
* (c) 1993 Marc Duponcheel *
* *
*********************************/
#include <exec/types.h>
#include <exec/memory.h>
#include <exec/execbase.h>
#include <libraries/dos.h>
#include <intuition/intuition.h>
#ifndef __GCC__
#include <proto/exec.h>
#include <proto/dos.h>
#else
#include <clib/exec_protos.h>
#include <dos/exall.h>
#include <clib/dos_protos.h>
#endif
#include <stdio.h>
#include <libraries/reqtools.h>
#ifndef __GCC__
#include <proto/reqtools.h>
#else
#include <clib/reqtools_protos.h>
#ifdef DEMO_INLINE
#define static
#define __inline
/* should become <inline/reqtools.h> once you installed it there */
#include "inline/reqtools.h"
#endif
#endif
extern struct ExecBase *SysBase;
struct ReqToolsBase *ReqToolsBase;
#define REG register
#ifdef DOHOOKS
#ifndef __GCC__
/* Callback functions
Define DOHOOKS when you compile to activate these filter functions */
BOOL __asm __saveds file_filterfunc (
REG __a0 struct Hook *, REG __a2 struct rtFileRequester *,
REG __a1 struct FileInfoBlock *
);
BOOL __asm __saveds font_filterfunc (
REG __a0 struct Hook *, REG __a2 struct rtFontRequester *,
REG __a1 struct TextAttr *
);
BOOL __asm __saveds vol_filterfunc (
REG __a0 struct Hook *, REG __a2 struct rtFileRequester *,
REG __a1 struct rtVolumeEntry *
);
#else
BOOL file_filterfunc ();
BOOL font_filterfunc ();
BOOL vol_filterfunc ();
#endif __GCC__
#endif DOHOOKS
ULONG undertag[] = { RT_Underscore, '_', TAG_END };
void myputs (char *str)
{
Write (Output(), str, strlen(str));
}
#ifndef __GCC__
_main()
#else
int main()
#endif
{
struct rtFileRequester *filereq;
struct rtFontRequester *fontreq;
struct rtScreenModeRequester *scrmodereq;
struct rtFileList *flist, *tempflist;
#ifdef DOHOOKS
struct Hook filterhook, font_filterhook, vol_filterhook;
#endif
char buffer[128], filename[34];
long longnum, ret, color;
if (!(ReqToolsBase = (struct ReqToolsBase *)
OpenLibrary (REQTOOLSNAME, REQTOOLSVERSION))) {
myputs ("You need reqtools.library V38 or higher!\n"
"Please install it in your Libs: drirectory.\n");
exit (0);
}
rtEZRequest ("ReqTools 2.0 Demo\n"
"~~~~~~~~~~~~~~~~~\n"
"'reqtools.library' offers several\n"
"different types of requesters:",
"Let's see them", NULL, NULL);
rtEZRequest ("NUMBER 1:\nThe larch :-)", "Be serious!", NULL, NULL);
rtEZRequest ("NUMBER 1:\nString requester\nfunction: rtGetString()",
"Show me", NULL, NULL);
strcpy (buffer, "A bit of text");
if (!rtGetString (buffer, 127, "Enter anything:", NULL, TAG_END))
rtEZRequest ("You entered nothing :-(", "I'm sorry", NULL, NULL);
else
rtEZRequest ("You entered this string:\n'%s'.",
"So I did", NULL, NULL, buffer);
ret = rtGetString (buffer, 127, "Enter anything:", NULL,
RTGS_GadFmt, " _Ok |New _2.0 feature!|_Cancel",
RTGS_TextFmt,
"These are two new features of ReqTools 2.0:\n"
"Text above the entry gadget and more than\n"
"one response gadget.",
TAG_MORE, undertag);
if (ret == 2)
rtEZRequest ("Yep, this is a new\nReqTools 2.0 feature!",
"Oh boy!", NULL, NULL);
ret = rtGetString (buffer, 127, "Enter anything:", NULL,
RTGS_GadFmt, " _Ok |_Abort|_Cancel",
RTGS_TextFmt,
"New is also the ability to switch off the\n"
"backfill pattern. You can also center the\n"
"text above the entry gadget.\n"
"These new features are also available in\n"
"the rtGetLong() requester.",
RTGS_BackFill, FALSE,
RTGS_Flags, GSREQF_CENTERTEXT|GSREQF_HIGHLIGHTTEXT,
TAG_MORE, undertag);
if (ret == 2)
rtEZRequest ("What!! You pressed abort!?!\nYou must be joking :-)",
"Ok, Continue", NULL, NULL);
rtEZRequest ("NUMBER 2:\nNumber requester\nfunction: rtGetLong()",
"Show me", NULL, NULL);
if (!rtGetLong (&longnum, "Enter a number:", NULL,
RTGL_ShowDefault, FALSE,
RTGL_Min, 0, RTGL_Max, 666,TAG_END))
rtEZRequest ("You entered nothing :-(",
"I'm sorry", NULL, NULL);
else
rtEZRequest ("The number you entered was:\n%ld%s",
"So it was", NULL, NULL, longnum,
(longnum == 666) ? " (you devil! :)" : "");
rtEZRequest ("NUMBER 3:\nMessage requester, the requester\n"
"you've been using all the time!\nfunction: rtEZRequest()",
"Show me more", NULL, NULL);
rtEZRequest ("Simplest usage: some body text and\na single centered gadget.",
"Got it", NULL, NULL);
while (!rtEZRequest ("You can also use two gadgets to\n"
"ask the user something.\n"
"Do you understand?", "Of course|Not really",
NULL, NULL))
rtEZRequest ("You are not one of the brightest are you?\n"
"We'll try again...",
"Ok", NULL, NULL);
rtEZRequest ("Great, we'll continue then.", "Fine", NULL, NULL);
switch (rtEZRequest ("You can also put up a requester with\n"
"three choices.\n"
"How do you like the demo so far ?",
"Great|So so|Rubbish", NULL, NULL)) {
case FALSE:
rtEZRequest ("Too bad, I really hoped you\nwould like it better.",
"So what", NULL, NULL);
break;
case TRUE:
rtEZRequest ("I'm glad you like it so much.", "Fine", NULL, NULL);
break;
case 2:
rtEZRequest ("Maybe if you run the demo again\n"
"you'll REALLY like it.",
"Perhaps", NULL, NULL);
break;
}
ret = rtEZRequestTags ("The number of responses is not limited to three\n"
"as you can see. The gadgets are labeled with\n"
"the return code from rtEZRequest().\n"
"Pressing Return will choose 4, note that\n"
"4's button text is printed in boldface.",
"1|2|3|4|5|0", NULL, NULL,
RTEZ_DefaultResponse, 4, TAG_END);
rtEZRequest ("You picked '%ld'.", "How true", NULL, NULL, ret);
rtEZRequestTags ("New for Release 2.0 of ReqTools (V38) is\n"
"the possibility to define characters in the\n"
"buttons as keyboard shortcuts.\n"
"As you can see these characters are underlined.\n"
"Pressing shift while still holding down the key\n"
"will cancel the shortcut.\n"
"Note that in other requesters a string gadget may\n"
"be active. To use the keyboard shortcuts there\n"
"you have to keep the Right Amiga key pressed down.",
"_Great|_Fantastic|_Swell|Oh _Boy",
NULL, NULL,
RT_Underscore, '_', TAG_END);
rtEZRequest (
"You may also use C-style formatting codes in the body text.\n"
"Like this:\n\n"
"'The number %%ld is written %%s.' will give:\n\n"
"The number %ld is written %s.\n\n"
"if you also pass '5' and '\"five\"' to rtEZRequest().",
"_Proceed", NULL, (struct TagItem *)&undertag, 5, "five");
if (rtEZRequestTags ("It is also possible to pass extra IDCMP flags\n"
"that will satisfy rtEZRequest(). This requester\n"
"has had DISKINSERTED passed to it.\n"
"(Try inserting a disk).",
"_Continue", NULL, NULL,
RT_IDCMPFlags, DISKINSERTED,
RT_Underscore, '_', TAG_END)
& DISKINSERTED)
rtEZRequest ("You inserted a disk.", "I did", NULL, NULL);
else
rtEZRequest ("You used the 'Continue' gadget\n"
"to satisfy the requester.", "I did", NULL, NULL);
rtEZRequestTags ("Finally, it is possible to specify the position\n"
"of the requester.\n"
"E.g. at the top left of the screen, like this.\n"
"This works for all requesters, not just rtEZRequest()!",
"_Amazing", NU